#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/statfs.h>
#include <linux/sched.h>
#include <linux/fs_struct.h>
MODULE_LICENSE("GPL");

static int vfs_statfs_init(void)
{
	int result=0, i=0;
	struct path path;
	struct dentry *dentry=NULL;
	static struct kstatfs buf;
	
	printk("into vfs_statfs_init\n");
	dentry = current->fs->pwd.dentry;
	path.dentry = dentry;
	path.mnt = current->fs->pwd.mnt;
	printk("the f_bsize is :%ld\n", buf.f_bsize);
	printk("the f_frsize is :%ld\n", buf.f_frsize);
	printk("the f_type is :%ld\n", buf.f_type);
	printk("the f_blocks is :%lld\n", buf.f_blocks);
	printk("the f_bfree is :%lld\n", buf.f_bfree);
	printk("the f_bavail is :%lld\n", buf.f_bavail);
	printk("the f_files is :%lld\n", buf.f_files);
	printk("the f_ffree is :%lld\n", buf.f_ffree);
	printk("the f_fsid is :%ld\n", buf.f_fsid);
	printk("the f_namelen is :%ld\n", buf.f_namelen);
	
	for(i=0; i<4; i++)
		printk("the f_spare[%d] is :%ld\n", i, buf.f_spare[i]);
	
	result= vfs_statfs(&path, &buf);
	printk("The result of function vfs_statfs is :%d\n", result);
	printk("the new value of the buf after vfs_statfs:\n");
	printk("the new f_bsize is :%ld\n", buf.f_bsize);
	printk("the new f_frsize is :%ld\n", buf.f_frsize);
	printk("the new f_type is :%ld\n", buf.f_type);
	printk("the new f_blocks is :%lld\n", buf.f_blocks);
	printk("the new f_bfree is :%lld\n", buf.f_bfree);
	printk("the new f_bavail is :%lld\n", buf.f_bavail);
	printk("the new f_files is :%lld\n", buf.f_files);
	printk("the new f_ffree is :%lld\n", buf.f_ffree);
	printk("the new f_fsid is :%ld\n", buf.f_fsid);
	printk("the new f_namelen is :%ld\n", buf.f_namelen);
	
	for(i=0; i<4; i++)
		printk("the new f_spare[%d] is :%ld\n", i, buf.f_spare[i]);
	printk("out vfs_statfs_init\n");
	
	return 0;
}

static void vfs_statfs_exit(void)
{
printk("Goodbye vfs_statfs\n");
}

module_init(vfs_statfs_init);
module_exit(vfs_statfs_exit);
